<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>


    <footer th:fragment="table">
        <div class="tpl-content-wrapper">
            <div class="row-content am-cf">
                <div class="row">
                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                        <div class="widget am-cf">
                            <div class="widget-head am-cf">
                                <div class="widget-title  am-cf">项目简介</div>
                            </div>
                            <div class="widget-body  am-fr">

                                <div class="am-u-sm-12 am-u-md-6 am-u-lg-4">
                                    <div class="am-form-group">
                                        <div class="am-btn-toolbar">
                                            <div class="am-btn-group am-btn-group-xs">
                                                <button type="button" class="am-btn am-btn-default am-btn-danger"
                                                        onclick="del()"><span class="am-icon-trash-o"></span> 删除
                                                </button>
                                                <button type="button" class="am-btn am-btn-default am-btn-warning"  data-toggle="modal" data-target="#myimportModal"><span class="am-icon-plus"></span> 导入</button>
                                                <button type="button" class="am-btn am-btn-default am-btn-secondary" onclick="derive()"><span class="am-icon-trash-o"></span> 导出</button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="am-u-sm-12 am-u-md-6 am-u-lg-2">
                                    <div class="am-form-group tpl-table-list-select">
                                        <select data-am-selected="{btnSize: 'sm'}" id="repaystatus" class="selectOption">
                                            <option value="">请选择</option>
                                            <option value="还未到期" th:selected="${repaystatus=='还未到期'}">还未到期</option>
                                            <option value="到期未还清" th:selected="${repaystatus=='到期未还清'}">到期未还清</option>
                                            <option value="已还清" th:selected="${repaystatus=='已还清'}">已还清</option>
                                        </select>
                                        <select data-am-selected="{btnSize: 'sm'}" id="pagesize" class="selectOption">
                                            <option value="">请选择</option>
                                            <option value="5" th:selected="${pagesize==5}">5</option>
                                            <option value="10" th:selected="${pagesize==10}">10</option>
                                            <option value="10" th:selected="${pagesize==15}">15</option>
                                            <option value="10" th:selected="${pagesize==20}">20</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="am-u-sm-12 am-u-md-6 am-u-lg-2">
                                    <div class="am-input-group am-input-group-sm tpl-form-border-form cl-p">
                                        <input type="date" class="am-form-field" th:value="${#dates.format(predate,'yyyy-MM-dd')}" id="predate">
                                    </div>
                                </div>
                                <div class="am-u-sm-12 am-u-md-6 am-u-lg-2">
                                    <div class="am-input-group am-input-group-sm tpl-form-border-form cl-p">
                                        <input type="date" class="am-form-field " th:value="${#dates.format(nextdate,'yyyy-MM-dd')}" id="nextdate">
                                    </div>
                                </div>
                                <div class="am-u-sm-12 am-u-md-6 am-u-lg-2">
                                    <div class="am-input-group am-input-group-sm tpl-form-border-form cl-p">
                                        <input type="text" class="am-form-field " id="repaykeyword" th:value="${repaykeyword}">
                                        <span class="am-input-group-btn">
                                         <button class="am-btn  am-btn-default am-btn-success tpl-table-list-field am-icon-search"
                                                 type="button" th:onclick="|page('${userrepay.pageNum}')|"></button>
                                    </span>
                                    </div>
                                </div>

                                <div class="am-u-sm-12">
                                    <div style="overflow-x:scroll">
                                        <table class="am-table am-table-compact am-table-striped tpl-table-black "
                                               id="example-r" style="width: 2000px">
                                            <thead>
                                            <tr>
                                                <th>
                                                    <button onclick="reSelect()"
                                                            class="am-btn  am-btn-default am-btn-success tpl-table-list-field"
                                                            type="button">反选
                                                    </button>
                                                </th>
                                                <th>编号</th>
                                                <th>用户名称</th>
                                                <th>贷款名称</th>
                                                <th>贷款时间</th>
                                                <th>本月应还</th>
                                                <th>本月已还</th>
                                                <th>本月未还</th>
                                                <th>待还金额</th>
                                                <th>总还款月份</th>
                                                <th>剩余还款月份</th>
                                                <th>贷款总金额</th>
                                                <th>还款状态</th>
                                                <th>操作</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <!--<div th:text="${userrepay}"></div>-->
                                            <tr class="gradeX" th:each="repay,s : ${userrepay.list}">
                                                <td><input type="checkbox" name="persons"  th:value="${repay.monloansId}" class="choice"></td>
                                                <th th:text="${s.index+1}"></th>
                                                <th th:text="${repay.userRealname}">用户名称</th>
                                                <th th:text="${repay.loansName}">贷款名称</th>
                                                <th th:text="${#dates.format(repay.monloansTime,'yyyy-MM-dd')}">贷款时间</th>
                                                <th th:text="${repay.monloansPaymonth}">本月应还</th>
                                                <th th:text="${repay.monloansPaynow}">本月已还</th>
                                                <th th:text="${repay.monloansPaybefore}">本月未还</th>
                                                <th th:text="${repay.monloansPaynext}">待还金额</th>
                                                <th th:text="${repay.monloansMonth}">总还款月份</th>
                                                <th th:text="${repay.monloansLastmonth}">剩余还款月份</th>
                                                <th th:text="${repay.monloansBalance}">贷款总金额</th>
                                                <th th:text="${repay.monloansStatus}">还款状态</th>
                                                <td>
                                                    <div class="tpl-table-black-operation">
                                                        <a href="javascript:;"  data-toggle="modal" data-target="#myModal1" th:onclick="|findmost('${repay.UserId}','${repay.loansId}')|">更多信息</a>
                                                        <a href="javascript:;" class="tpl-table-black-operation-del">
                                                            <i class="am-icon-trash" th:onclick="|delone('${repay.monloansId}')|"></i> 删除
                                                        </a>
                                                        <!--等待功能-->
                                                        <!--<a href="javascript:;" class="tpl-table-black-operation-del">-->
                                                            <!--<i class="am-icon-trash"></i> 提醒用户-->
                                                        <!--</a>-->
                                                    </div>
                                                </td>
                                            </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                    <div class="am-u-lg-12 am-cf">
                                        <div class="am-u-lg-3">
                                            跳转至:<input type="number" id="num"  class="selectOption">/ 页
                                            <span>
                                            <button class="am-btn  am-btn-default am-btn-success tpl-table-list-field am-icon-search" type="button" th:onclick="findpage()"></button>
                                        </span>
                                        </div>

                                        <div class="am-fr">
                                            <ul class="am-pagination tpl-pagination">
                                                <li ><a href="javascript:" th:onclick="|page('${userrepay.navigateFirstPage}')|">首页</a></li>
                                                <li  th:if="userrepay.hasPreviousPage"><a href="javascript:" th:onclick="|page('${userrepay.prePage}')|">«</a></li>


                                                <li th:each="pageNum:${#numbers.sequence(1,userrepay.pages)}">
                                                    <a th:text="${pageNum}" th:onclick="|page('${pageNum}')|"></a>
                                                </li>


                                                <li th:if="userrepay.hasNextPage"><a href="javascript:" th:onclick="|page('${userrepay.nextPage}')|">»</a></li>
                                                <li><a href="javascript:" th:onclick="|page('${userrepay.navigateLastPage}')|">尾页</a></li>
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>


            <div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="margin-top: 100px">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title" id="myModalLabel">查看充值更多信息</h4>
                        </div>
                        <div id="modele">

                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        </div>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal -->
            </div>




            <!--导入模态框-->
            <div class="modal fade" id="myimportModal" tabindex="-1" role="dialog" aria-labelledby="myimportModalLabel" aria-hidden="true" style="margin-top: 300px">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title" id="myimportModalLabel">查看充值更多信息</h4>
                        </div>
                        请选择需要上传的文件：<input type="file" name="file" id="importfile">
                        <div class="modal-footer">
                            <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="importscore2()">提交</button>
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        </div>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal -->
            </div>

        </div>
    </footer>
    <script>



        function page(i) {

            $.ajax({
                url:"/p2p/myrepay/getUserRepay",
                data:{
                    "repaystatus":$("#repaystatus").val(),
                    "predate":$("#predate").val(),
                    "nextdate":$("#nextdate").val(),
                    "repaykeyword":$("#repaykeyword").val(),
                    "pagenum":i,
                    "pagesize":$("#pagesize").val()
                },
                type:"get",
                dataType:"html",
                success:function (data) {
                    $("#content").html(data)
                }
            })
        }

        function findpage() {
            var pagesnum=$('#num').val();
            page(pagesnum);
        }


        function findmost(i,n) {
            $.ajax({
                url: "/p2p/myrepay/getdetail",
                data:{"id":i,"id2":n},
                type: "get",
                dataType:"json",
                success:function (data) {
                    console.log(data)
                    var s="";
                    s+="<div class=\"modal-body\">\n" +
                        "用户的真实姓名:<div>"+data.userRealname+"</div>\n" +
                        "用户收益:<div>"+data.userGetmoney+"</div>\n" +
                        "贷款名称:<div>"+data.loansName+"</div>\n" +
                        "贷款金额:<div>"+data.loansMoney+"</div>\n" +
                        "贷款时间:<div>"+data.loansTime+"</div>\n" +
                        "贷款电话:<div>"+data.loansPhone+"</div>\n" +
                        "贷款状态:<div>"+data.loansState+"</div>\n" +
                        "贷款月份:<div>"+data.loansMonth+"</div>\n" +
                        "贷款物品的价值:<div>"+data.loansTotalvalue+"</div>\n" +
                        "\n" +
                        "</div>"
                    $('#modele').html(s)
                },
            })
        }


        //删除单个
        function delone(i) {
            $.ajax({
                url:"/p2p/myrepay/delonerepay",
                data:{
                    "id":i,
                },
                type:"get",
                dataType:"text",
                success:function (data) {
                    if(data==1){
                        alert("恭喜删除成功")
                        page(1);
                    }else{
                        alert("清先删除项目,再进行删除,删除失败!")
                    }
                }
            })
        }


        $(".choice").click(function () {
            if($(this).prop("checked")){
                if(!($(this).val() in rep)){
                    rep.push($(this).val())
                }
            }else if(!$(this).prop("checked")){
                for (var i=0;i<rep.length;i++){
                    if(rep[i]===$(this).val()){
                        rep.splice(i,1);
                    }
                }
            }
        })


        //批量删除
        function del() {
            var ides=rep;
            $.ajax({
                url:"/p2p/myrepay/delallrepay",
                data:{
                    "id":ides,
                },
                type:"get",
                dataType:"text",
                success:function (data) {
                    if(data==1){
                        alert("恭喜删除成功");
                        page(1);
                        rep=[];
                    }else {
                        alert("清先删除项目,再删除项目公司还款信息,谢谢!");
                    }
                }
            })
        }

        /*导出*/
        function derive() {
            if(rep.length>0){
                location.href="/p2p/myrepay/outputrepay?ids="+rep
                rep=[];
            }else{
                alert("请先选择！")
            }
        }


        //导入
        function importscore2() {
            var form = new FormData();
            form.append("file", document.getElementById("importfile").files[0]);
            $.ajax({
                url:"/p2p/myrepay/inrepay",
                data:form,
                type:"post",
                dataType:"text",
                processData: false,
                contentType: false,
                success:function (data) {
                    if(data==1){
                        page(1);
                        alert("导入成功")
                    }else{
                        alert("导入失败")
                    }
                },
            })
        }





    </script>
</head>
</html>

